//
//  main.swift
//  SwiftMirror
//
//  Created by edy on 2025/10/7.
//

import Foundation

//let tObject = "Hello"
//
//let mirror = Mirror(reflecting: tObject)
//print(mirror)
//
//print("Type: \(mirror.subjectType)")

//struct Person {
//    
//    var name: String
//    var age: Int
//    
//}
//
//let person = Person(name: "wen", age: 35)
//let pMirror = Mirror(reflecting: person)
//
//for child in pMirror.children {
//    if let ptName = child.label {
//        print("\(ptName), \(child.value)")
//    }
//}

class Animal {
    
    var species: String
    init(species: String) {
        self.species = species
    }
    
}

class Dog: Animal {
    
    var name: String
    init(name: String, species: String) {
        self.name = name
        super.init(species: species)
    }
    
}

let dog = Dog(name: "Abc", species: "CC")
let dMirror = Mirror(reflecting: dog)

if let spClassMirror = dMirror.superclassMirror {
    print("Superclass Type: \(spClassMirror.subjectType)")
}
